package com.razorthink.shell.utils;

import java.io.File;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class Commons {
	public static Collection<File> listFilesRecursively(File dir) {
		Set<File> fileTree = new HashSet<File>();
		for (File entry : dir.listFiles()) {
			if (entry.isFile()) {
				// if a file is a SVN revision of a source file, don't add it.
				if (!entry.getAbsolutePath().endsWith(".svn-base")) {
					fileTree.add(entry);
				}
			} else {
				// if a directory is a root directory of SVN directory, don't
				// add it.
				if (!entry.getAbsolutePath().endsWith(".svn")) {
					fileTree.addAll(listFilesRecursively(entry));
				}
			}
		}
		return fileTree;
	}
}
